package com.cqust.aspect;

import org.aspectj.lang.JoinPoint;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LoginAdvice {
    public void before() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss E");
        String time = sdf.format(date);
        System.out.println("登录时间："+time);
    }
    public void after(JoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        HttpSession session = (HttpSession) args[2];
        String name = (String) session.getAttribute("Name");
        System.out.println("登录用户："+name);
    }
}
